/*
 * @Descripttion: GGB
 * @version: 1.0
 * @Author: GGB
 * @Date: 2021-08-19 07:54:47
 * @LastEditors: GGB
 * @LastEditTime: 2021-08-19 08:03:19
 */
import 'package:file_picker/file_picker.dart';
import 'package:flutter/material.dart';

class FileList extends StatelessWidget {
  const FileList({Key key, this.files, this.onDel}) : super(key: key);
  final List<PlatformFile> files;
  final ValueChanged<int> onDel;

  @override
  Widget build(BuildContext context) => Container(
        padding: EdgeInsets.all(8),
        decoration: BoxDecoration(
          color: Colors.grey.withOpacity(0.2),
          borderRadius: BorderRadius.circular(10),
        ),
        child: ListView.builder(
          shrinkWrap: true,
          itemCount: files.length,
          itemBuilder: (context, index) => Row(
            children: [
              Expanded(
                child: Text(
                  files[index].name,
                  maxLines: 3,
                  overflow: TextOverflow.ellipsis,
                  style: TextStyle(
                    fontSize: 14,
                  ),
                ),
              ),
              SizedBox(width: 10),
              IconButton(
                onPressed: () => onDel(index),
                icon: Icon(
                  Icons.close,
                ),
              )
            ],
          ),
        ),
      );
}
